//package com.sdgs.paas.sdk.core.mq;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.event.ContextRefreshedEvent;
//import org.springframework.context.event.EventListener;
//import org.springframework.util.Assert;
//
//import com.ctg.mq.api.exception.MQException;
//import com.sdgs.paas.sdk.core.log.PaasLogger;
//
///**
// * ctgmq功能自动配置
// *
// * @author wjj
// */
//@Configuration
//@ConditionalOnClass({ ICtgMqManager.class })
//@EnableConfigurationProperties(CtgMqConfig.class)
//public class CtgMqAutoConfiguration {
//
//	@Autowired
//	private ApplicationContext ctx;
//
//	@EventListener(ContextRefreshedEvent.class)
//	public void startup(ContextRefreshedEvent event) {
//		ctx.getBean(ICtgMqManager.class).consumeStart();
//	}
//	
//	@Bean
////	@DependsOn({"externalRestTemplate"})
//	// @ConditionalOnProperty(prefix = "ctgmq",name="enable",havingValue="on")
//	public ICtgMqManager ctgMqManager(CtgMqConfig ctgMqConfig, ApplicationContext applicationContext)
//			throws ClassNotFoundException, InstantiationException, IllegalAccessException, MQException {
//
//		Assert.notNull(ctgMqConfig, "CtgMq配置文件未正确加载！");
//		ICtgMqManager ctgMqManager = new CtgMqManager(ctgMqConfig,applicationContext);
//		if(!ctgMqConfig.isDisableConsumer()){
//			Assert.notNull(ctgMqConfig.getConsumerGroup(), "CtgMq消费者配置未正确加载！");
//			ctgMqManager.startConsumer(ctgMqConfig.getNamesrvAddr(), ctgMqConfig.getConsumerGroup(),
//					ctgMqConfig.getAuthID(), ctgMqConfig.getAuthPWD(), ctgMqConfig.isConsumeOrderly(),
//					ctgMqConfig.getBatchSize(), ctgMqConfig.getConsumerClientCallbackExecutorThreads(),
//					ctgMqConfig.getConsumerClientWorkerThreads(),
//					ctgMqConfig.getConsumerAbMsgProcNetCallbackExecutorThreads(),
//					ctgMqConfig.getConsumerAbMsgProcNetWorkerThreads());
//			PaasLogger.info("CtgMqManager 消费者启动成功!");
//		}
//		if(!ctgMqConfig.isDisableProducer()){
//			Assert.notNull(ctgMqConfig.getProducerGroup(), "CtgMqManager 生产者配置未正确加载！");
//			ctgMqManager.startProducer(ctgMqConfig.getNamesrvAddr(), ctgMqConfig.getProducerGroup(),
//					ctgMqConfig.getAuthID(), ctgMqConfig.getAuthPWD(), ctgMqConfig.getMaxMessageSize(),
//					ctgMqConfig.getSendMsgTimeout(), ctgMqConfig.getCompressMsgBodyOverHowmuch());
//			PaasLogger.info("CtgMqManager 生产者启动成功!");
//		}
//		if(!ctgMqConfig.isDisablePullConsumer()){
//			Assert.notNull(ctgMqConfig.getPullConsumerGroup(), "CtgMqManager Pull消费者配置未正确加载！");
//			ctgMqManager.startPullConsumer(ctgMqConfig.getNamesrvAddr(), ctgMqConfig.getAuthID(), ctgMqConfig.getAuthPWD());
//			PaasLogger.info("CtgMqManager Pull消费者启动成功!");
//		}
//
//
//		return ctgMqManager;
//	}
//
//}
